<div class="container">

	<?php echo $this->session->flash(); ?>
	
	<div class="panel panel-default">
		<table class="table" style="width:100% !important;">
			<thead>
				<tr>
					<th>#</th>
					<th>Category</th>
					<th>Product Name</th>
					<th>Description</th>
					<th>Price</th>
					<th>Sale-Off Price</th>
					<th>Made In</th>
					<th>Views</th>
					<th>Is special</th>					
					<th>Status</th>
					<th>
						<a href="<?php echo $this->webroot; ?>product/add">
							<button type="button" class="btn btn-primary">New</button>
						</a>
					</th>
				</tr>
	      	</thead>
	      
			<tbody>
			
				<?php $index = 0; foreach($list as $item): $index++; ?>
				
					<?php if($index % 2 != 0) { ?>
						<tr class="info">
					<?php } else { ?>
						<tr>
					<?php } ?>
					
						<td>
							<a href="<?php echo $this->webroot; ?>product/edit?id=<?php echo $item['Product']['id']; ?>"><?php echo $item['Product']['id']; ?></a>
						</td>
						
						<td>
							<?php foreach($category as $cate): if($cate['Category']['id'] == $item['Product']['category_id']) { echo $cate['Category']['category_name']; } ?>
							<?php endforeach; ?>							
						</td>
						
						<td>
							<a href="<?php echo $this->webroot; ?>product/edit?id=<?php echo $item['Product']['id']; ?>"><?php echo $item['Product']['product_name']; ?></a>
						</td>
						
						<td>
							<?php if(strlen($item['Product']['description']) > 50) { ?>
								<?php echo substr($item['Product']['description'], 0, 50); ?>...
							<?php } else { ?>
								<?php echo $item['Product']['description']; ?>
							<?php } ?>							
						</td>
						
						<td>
							<?php echo $item['Product']['price']; ?>
						</td>
						
						<td>
							<?php echo $item['Product']['sale_off']; ?>
						</td>
						
						<td>
							<?php echo $item['Product']['made_in']; ?>
						</td>
						
						<td>
							<?php echo $item['Product']['view']; ?>
						</td>
						
						<td>
							<?php if($item['Product']['special'] == 1) { ?>
								<span class="label label-success">Special</span>
							<?php } else { ?>
								<span class="label label-default">Normal</span>
							<?php } ?>
						</td>
						
						<td>
							<?php if($item['Product']['status'] == 1) { ?>
								<span class="label label-success">In Stock</span>
							<?php } else { ?>
								<span class="label label-default">Out of Stock</span>
							<?php } ?>
						</td>
						
						<td>
							<a onClick="return confirm('Delete this product ?');" href="<?php echo $this->webroot; ?>product/delete?id=<?php echo $item['Product']['id']; ?>">
								<button type="button" class="btn btn-danger">Delete</button>
							</a>							
						</td>
					</tr>	
				<?php endforeach; ?>
				
			</tbody>
	    </table>
	</div>
</div>